package com.jyw.framework.security.wechat;

import com.jyw.framework.web.service.WechatDetailsService;
import org.springframework.security.config.annotation.SecurityConfigurerAdapter;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.web.DefaultSecurityFilterChain;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author 沈峻
 * @ClassName WechatAuthenticationSecurityConfig
 * @Description TODO
 * @Date 2023/9/5 16:45
 **/
@Component
public class WechatAuthenticationSecurityConfig extends SecurityConfigurerAdapter<DefaultSecurityFilterChain, HttpSecurity> {

    @Resource
    private WechatDetailsService detailsService;

    @Override
    public void configure(HttpSecurity http) throws Exception {
        WechatAuthenticationProvider smsCodeAuthenticationProvider = new  WechatAuthenticationProvider();
        smsCodeAuthenticationProvider.setUserDetailsService(detailsService);

        http.authenticationProvider(smsCodeAuthenticationProvider);
    }
}
